package com.jh.dao;

import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import org.springframework.jdbc.core.JdbcTemplate;

import com.jh.model.KQ;
import com.jh.socket.TcpParseOut;
import com.jh.util.SpringContextUtil;

public class KQDao {
	
	public int Save(KQ kq,int schoolID){
		JdbcTemplate jt = (JdbcTemplate) SpringContextUtil.getBean("jdbcTemplate");
		jt.update("insert into kq"+schoolID+"(classID,Scode,type,DKtime)VALUES(?,?,?,?)", 
				new Object[]{kq.getClassID(),kq.getScode(),kq.getType(),kq.getDKtime()},
				new int[]{java.sql.Types.INTEGER,java.sql.Types.VARCHAR,java.sql.Types.INTEGER,java.sql.Types.DATE});
		return 0;
		
	}
	
	public static void main(String arg[]){
		KQDao kd = new KQDao();
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Calendar cal = Calendar.getInstance();
		KQ kq = new KQ();
		kq.setScode("X3333");
		kq.setType(1);
		kq.setClassID(2);
		kq.setDKtime(cal.getTime());
		int schoolID = 6;
		kd.Save(kq, schoolID);
		//System.out.println(String.format("%04s","20"));
		//System.out.println(TcpParseOut.getPageLength("02ERRORRRR"));
	}

}
